package test1;

public class Ticket implements Runnable {
    private static int count = 100;

    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                if (count == 0) {
                    break;
                } else {
                    count--;
                    System.out.println(Thread.currentThread().getName() + "卖票中...还剩" + count + "张票");
                }
            }
        }
    }
}
